﻿<cfsilent>
	<cfscript>

		event.setArg("pageTitle", "外语等级考试");

		sessionAdvice = getProperty("serviceFactory").getBean("sessionAdvice");
		datetimeAdvice = getProperty("serviceFactory").getBean("datetimeAdvice");
		dictAdvice = getProperty("serviceFactory").getBean("senateDictionaryAdvice");

		termId = event.getArg("TermID");

		academicYear = event.getArg("AcademicYear");
		academicTerm = event.getArg("AcademicTerm");
		
		currentTab = event.getArg("TabID", "labWelcome");
		
		/* 学籍相关信息 */
		studentId = sessionAdvice.getAutherUserID();

		/* 可报考科目 */
		sql = "	SELECT
					c.exam_id,c.exam_name,
					c.date_start,c.date_end,c.time_start,c.time_end,c.grade_allowed,c.institute_allowed,c.exam_charge
				FROM
					t_cet c
				WHERE
					SUBSTR(c.exam_prop,1,1)='1'
				ORDER BY
					c.exam_id";
		
		queryObj = new Query(datasource = application.dnsSlave);
		rs_cet = queryObj.execute(sql=sql).getResult();
		
		/* 本期已报考科目 */
		sql = "	SELECT
					ce.exam_id,ce.apply_date,c.exam_charge,ce.is_charged
				FROM
					t_cet_entry ce
					INNER JOIN t_cet c ON c.exam_id = ce.exam_id
				WHERE
					ce.stu_id = :studentId 
					AND
					ce.term_id = :termId 
				ORDER BY
					ce.eid DESC";
		
		queryObj = new Query(datasource = application.dnsSlave);
		
		queryObj.addParam(name="studentId", value=studentId, cfsqltype="cf_sql_varchar");
		queryObj.addParam(name="termId", value=termId, cfsqltype="cf_sql_char");
		
		rs_entry = queryObj.execute(sql=sql).getResult();
		
		/* 以往考试成绩 */
		sql = "	SELECT
					cs.exam_id,cs.scroll_id,cs.absent,cs.scroll,
					cs.listening,cs.reading,cs.writing,cs.integration
				FROM
					t_cet_scroll cs
				WHERE
					cs.stu_id = :stuId 
				ORDER BY
					cs.scroll_id DESC";
					
		queryObj = new Query(datasource = application.dnsSlave);
		
		queryObj.addParam(name="stuId", value=studentId, cfsqltype="cf_sql_varchar");
		
		rs_scroll = queryObj.execute(sql=sql).getResult();
		
		//writeDump(rs_scroll);
		//abort;

	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 link"></i><cfoutput>#academicYear#</cfoutput>学年 <cfoutput>#dictAdvice.getTerm(academicTerm)#</cfoutput> - 外语等级考试
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="welcome">
				<div class="UItab">
					<div class="tabLables">
						<span <cfif currentTab eq "labWelcome">class="active"</cfif> id="labWelcome" tabTarget="Welcome">报考科目</span>
						<span <cfif currentTab eq "labScroll">class="active"</cfif> id="labScroll" tabTarget="Scroll">已往考试成绩</span>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					
					// -->
					//]]>
				</script>
				<div id="Welcome" class="tabContent">
					
					<div class="noticeBlock">
						<h3>可报考科目</h3>
						<hr/>
					</div>
					
					<cfif rs_cet.recordCount eq 0>
						<div class="systemNotice">
							<h3><span class="img icon16x16 info"></span>尚无报考科目</h3>
							<p>当前没有您可报考的全国大学外语四六级考试语言级别.</p>
						</div>
					</cfif>
					
                    <cfif rs_cet.recordCount>
					
						<table id="cetList" class="UIEditable">
							<thead>
								<tr>
									<td width="120">语言级别</td>
									<td width="220">报考时间段</td>
									<td width="60">报名费</td>
									<td>可报考年级</td>
									<td align="right">报考学院</td>
								</tr>
							</thead>
							<tbody>
								<cfloop query="rs_cet">						
									<tr class="editRows" rowid="<cfoutput>#rs_cet.exam_id#</cfoutput>">
										<td><span class="numeric"><cfoutput>#rs_cet.exam_id#</cfoutput> - </span><strong><cfoutput>#rs_cet.exam_name#</cfoutput></strong></td>
										<td>
											<span class="numeric"><cfoutput>#datetimeAdvice.formatDateString(rs_cet.date_start, 'MM/DD')#</cfoutput> - <cfoutput>#datetimeAdvice.formatDateString(rs_cet.date_end, 'MM/DD')#</cfoutput></span>
											<cfif rs_cet.time_start eq "0001" and rs_cet.time_end eq "2359">
												全天
												<cfelse>
												<span class="numeric"><cfoutput>#datetimeAdvice.formatTimeString(rs_cet.time_start, 'HH:MI')#</cfoutput> ~ <cfoutput>#datetimeAdvice.formatTimeString(rs_cet.time_end, 'HH:MI')#</cfoutput></span>	
											</cfif>
										</td>
										<td><span class="numeric"><cfoutput>#numberFormat(rs_cet.exam_charge, '__.__')#</cfoutput></span></td>
										<td><cfif rs_cet.grade_allowed eq "ALL">全部<cfelse><span class="numeric"><cfoutput>#replace(rs_cet.grade_allowed, ",", " | ", "all")#</cfoutput></span></cfif></td>
										<td align="right">
											<cfif rs_cet.institute_allowed eq "ALL">全部
												<cfelse>
                                                <cfset sql = "	SELECT
																	i.institute_short
																FROM
																	t_institute i
																WHERE
																	i.institute_id in ( :insIds ) "/>
                                                <cfset queryObj = new Query(datasource = application.dnsSlave)/>
                                                <cfset queryObj.addParam(name="insIds", value=rs_cet.institute_allowed, cfsqltype="cf_sql_char", list=true)/>
                                                <cfset rs_select = queryObj.execute(sql=sql).getResult()/>
                                               	<cfoutput>#valueList(rs_select.institute_short, " | ")#</cfoutput>
											</cfif>
										</td>
									</tr>
							
								</cfloop>

							</tbody>
						</table>

					</cfif>
					
					<div class="noticeBlock">
						<h3>本学期已报考科目</h3>
						<hr/>
					</div>
					
					<cfif rs_entry.recordCount>
							<table id="entryList" class="UIEditable">
								<tbody>
                                    <cfloop query="rs_entry">
										<tr>
											<td><span class="numeric bold"><cfoutput>#rs_entry.exam_id#</cfoutput></span></td>
											<td>报名时间 <span class="numeric"><cfoutput>#datetimeAdvice.formatDateTimeString(rs_entry.apply_date)#</cfoutput></span></td>
											<td>报名费 <span class="numeric"><cfoutput>#numberFormat( rs_entry.exam_charge, "__.__")#</cfoutput></span></td>
											<td align="right"><cfif rs_entry.is_charged eq "0">尚未结算<cfelse>已收费</cfif></td>
										</tr>
									</cfloop>
								</tbody>
							</table>
							
						<cfelse>
							<div class="systemNotice">
								<h3><span class="img icon16x16 info"></span>本学期尚未报名参加外语水平测试</h3>
							</div>
					</cfif>
					
				</div>
				<div id="Scroll" class="tabContent">
				
					<div class="noticeBlock">
						<h3>四六级考试成绩</h3>
						<hr/>
					</div>
					
                    <cfif rs_scroll.recordCount eq 0>
						<div class="systemNotice">
							<h3><span class="img icon16x16 info"></span>尚无历史成绩</h3>
							<p>当前还没有您的四六级考试成绩, 可能考试成绩尚未下发到学校 或 之前您没有报考.</p>
						</div>
					</cfif>
					
					<cfif rs_scroll.recordCount>
						<table id="cetList" class="UIEditable">
							<thead>
								<tr>
									
									<td width="180">准考证号</td>
									<td>考试场次</td>
									<td width="60">语言级别</td>
									<td width="40">总分</td>
									<td width="40">听力</td>
									<td width="40">阅读</td>
									<td width="40">写作</td>
									<td width="40">综合</td>
								</tr>
							</thead>
							<tbody>
                                <cfloop query="rs_scroll">
									<tr class="editRows" rowid="<cfoutput>#rs_scroll.scroll_id#</cfoutput>">
										<td><span class="numeric"><cfoutput>#rs_scroll.scroll_id#</cfoutput></span></td>
										<td>20<cfoutput>#mid(rs_scroll.scroll_id, 7, 2)#</cfoutput>年<cfif mid(rs_scroll.scroll_id, 9, 1) eq "1">夏季<cfelse>冬季</cfif></td>
										<td><span class="numeric"><cfoutput>#rs_scroll.exam_id#</cfoutput></span></td>
										<cfif rs_scroll.absent eq "1">
												<td colspan="5" align="center" class="alertCell">缺考</td>
											<cfelse>
												<td><span class="numeric bold"><cfoutput>#rs_scroll.scroll#</cfoutput></span></td>
												<td><span class="numeric"><cfoutput>#rs_scroll.listening#</cfoutput></span></td>
												<td><span class="numeric"><cfoutput>#rs_scroll.reading#</cfoutput></span></td>
												<td><span class="numeric"><cfoutput>#rs_scroll.writing#</cfoutput></span></td>
												<td><span class="numeric"><cfoutput>#rs_scroll.integration#</cfoutput></span></td>
										</cfif>
									</tr>
								</cfloop>
							</tbody>
						</table>
						
					</cfif>
					
				</div>
			</div>
		</li>
	</ul>
</div>
